/** @file ShowSplash.qml
@brief Splasch screen loader with animation.

@todo Add a parametrized set of different animations.

@authorname \n
@licenseversion \n
@actualversion - @dateupdate

@licensenote
*/

import QtQuick 1.0

Item {
    id: shower

    property string customSplash: ""
    property int slpashAnimDuration: 1
    property int waitDuration: 1
    opacity: 1
    width: parent.width; height: parent.height

    property alias destroySplash: splashLoad.source

    Timer {
        id: waitCycle
        interval: waitDuration; running: false; repeat: false
        onTriggered: { shower.state = "reanchored"; }
    }

    // Defines the anchors.top so the state "reanchored" can modify the position
    anchors.top: parent.top

    Loader {
        id: splashLoad
        height: parent.height;
        width: parent.width
        source: customSplash;
        onLoaded: { waitCycle.running = true; }
    }

    // Out state definition, managed by the animation transition
    states: State {
        name: "reanchored"
        AnchorChanges { target: shower; anchors.top: parent.bottom }
    }

    // Definition of the animation when exiting.
    transitions: Transition {
        AnchorAnimation {
            id: hidingSplash
            duration: slpashAnimDuration;
            easing.amplitude: 1;
            easing.type: Easing.OutBounce
        }
    }
}
